CC	= avr-gcc
MCU	= atmega88p
COMMON	= -mmcu=$(MCU)
INCLUDES= -I/usr/lib/avr/include
CFLAGS	= -Wall -O3 $(COMMON)
LDFLAGS	= -Wl,-Map=atmega88p.map $(COMMON)
OBJECTS	= main.o
TARGET	= simple
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature

all:	$(TARGET) $(TARGET).hex size

$(OBJECTS): main.c
	$(CC) $(INCLUDES) $(CFLAGS) -c $<

$(TARGET): $(OBJECTS)
	$(CC) $(LDFLAGS) $(OBJECTS) -o $(TARGET)

$(TARGET).hex: $(TARGET)
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@

size: ${TARGET}
	@echo
	@avr-size -C --mcu=${MCU} ${TARGET}

clean:
	-rm -rf $(OBJECTS) dep/* $(TARGET) $(TARGET).hex

